{include file='public/head'}
<body>
<style type="text/css" media="screen">
header {
    color: black;
}
</style>
<div class="x-body" >
	<form class="layui-form" id='mainForm' method="post" action="addPro">

		<div class="layui-form-item">
                <label class="layui-form-label">
                    报修科室
                </label>
                <div class="layui-input-block">
                    <select lay-filter="aihao" name="room" id='room'>
                            <option value="1" selected>科室 1</option>
			                <option value="2">科室 2</option>
			                <option value="3">科室 3</option>
			                <option value="4">科室 4</option>
			                <option value="5">科室 5</option>
                    </select>
                </div>
        </div>

		  <div class="layui-form-item">
		    <label class="layui-form-label">报修人电话</label>
		    <div class="layui-input-block">
		    <input type="text" id="phone"  name="phone" lay-verify="required|phone" autocomplete="off" placeholder="请输入手机号" class="layui-input">
		    </div>
		  </div>

		<div class="layui-form-item">
		    <label class="layui-form-label">故障位置</label>
		    <div class="layui-input-block">
		    <input type="text" id="place"  name="place" lay-verify="required|place" placeholder="请输入故障位置" autocomplete="off" class="layui-input">
		    </div>
	  	</div>


		<div class="layui-form-item">
		    <label class="layui-form-label">报修人</label>
		    <div class="layui-input-block">
		    <input type="text" id="telMan" name="telMan" lay-verify="required|telMan placeholder="请输入报修人名字"  autocomplete="off" class="layui-input">
		    </div>
		    
		</div>

		<div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">故障信息</label>
		    <div class="layui-input-block">
		      <textarea placeholder="请描述故障信息" lay-verify="required|desc" class="layui-textarea" name="desc"></textarea>
		    </div>
	  	</div>

		<div class="layui-form-item">
                <label class="layui-form-label">
                    故障分类
                </label>
                <div class="layui-input-block">
                    <select lay-filter="aihao" name="cate_id" id='cate_id'>
                        <option value="1" selected>故障类型1</option>
                        <option value="2">故障类型2</option>
                        <option value="3">故障类型3</option>
                        <option value="4">故障类型4</option>
                    </select>
                </div>
        </div>

		<div class="layui-form-item">
		    <label class="layui-form-label">紧急程度</label>
		    <div class="layui-input-block">
		    	<input type="radio" value="1" name="emer" class="layui-input" title="常规">
		    	<input type="radio" value="2" name="emer" class="layui-input" title="紧急">
		    </div>
		</div>
		<input type="hidden" name="u_id">


		<div class="layui-form-item">
		    <div class="layui-input-block">
		      <button style="margin-left: 20%" class="layui-btn" lay-submit="" lay-filter="toSubmit">提交</button>
		      <button id="reset" type="reset" class="layui-btn layui-btn-primary">重置</button>
		    </div>
		</div>

	</form>
</div>
</body>
{include file='public/foot'}
<script type="text/javascript">
		var form = layui.form;
		var layer = layui.layer;
			  //自定义验证规则
			  // form.verify({
			  //   desc: function(value){
			  //     if(value.length < 6){
			  //       return '故障描述太少';
			  //     }
			  //   }
			  // });
		//监听提交
		form.on('submit(demo1)', function(data){
		      layer.alert(JSON.stringify(data.field), {
		      title: '最终的提交信息'
		    })
		    return false;
		  });

	$(document).ready(function(){ 
	     var options = {
		      type:'post',           //post提交
		      //url:'http://ask.tongzhuo100.com/server/****.php?='+Math.random(),   //url
		      dataType:"json",        //json格式
		      data:{},    //如果需要提交附加参数，视情况添加
		      clearForm: false,        //成功提交后，清除所有表单元素的值
		      resetForm: false,        //成功提交后，重置所有表单元素的值
		      cache:false,          
		      async:false,          //同步返回
		      success:function(data){
		      	console.log(data);
		      	if(data.code==0){
		      		layer.msg(data.msg);
		      	}else{
		      		layer.msg(data.msg,{icon:1,time:500},function(){
		      			$("#reset").click();
		      			x_admin_close();
		      			parent.location.reload();
		      		});
		      	}
		      //服务器端返回处理逻辑
		      	},
		      	error:function(XmlHttpRequest,textStatus,errorThrown){
		        	layer.msg('操作失败:服务器处理失败');

		      }
		    }; 
	    // bind form using 'ajaxForm' 
	    $('#mainForm').ajaxForm(options).submit(function(data){
	    	//无逻辑
	    }); 

	});
	
</script>
